package cn.buk.tms.dto;

import cn.buk.common.util.DecimalUtil;
import cn.buk.tms.entity.misc.FlightInfo;
import cn.buk.tms.entity.misc.PaymentMethod;
import cn.buk.tms.entity.misc.Supplier;
import cn.buk.tms.common.dto.PaymentMethodDto;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用于报表的改签
 * @author william
 *
 */
public class ReportFlightChangeDto extends ReportBaseDto{

	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private final Date opDate;
	private final double airChangeCharge; // 航司改签费
	private final String newTicketNo;
	private final String newPnrNo;
	private final String oldPnrNo;
	private final int intlTicket;

	public ReportFlightChangeDto(String balanceCode, String ticketNo, Date opDate, String passengerName, String routeDetail,
                                 double parvalue, double tax, double airChangeCharge, double serviceCharge,
                                 String newTicketNo, String newPnrNo, String oldPnrNo, int intlTicket,
                                 String op1, String op2, String op3, int customerType, int billId, Supplier supplier, PaymentMethod pm, Integer customerId) {
		super(op1, op2, op3, customerType, customerId);

		this.balanceCode = balanceCode;
		this.ticketNo = ticketNo;
		this.opDate = opDate;
		this.passengerName = passengerName;
		this.routeDetail = routeDetail;

		this.parvalue = parvalue;
		this.tax = tax;
		this.airChangeCharge = airChangeCharge; // 航司退票费
		this.serviceCharge = serviceCharge; // 服务费

		this.profit = serviceCharge;

		this.newTicketNo = newTicketNo;
		this.newPnrNo = newPnrNo;
		this.oldPnrNo = oldPnrNo;
		this.intlTicket = intlTicket;

		this.billId = billId;

		this.supplier = SupplierDto.createBySupplier(supplier);
		this.paymentMethod = PaymentMethodDto.create(pm.getId(), pm.getName());
	}

	private int id;

	private String balanceCode;

	private String ticketNo;

	private String ticketClass = "000";

	private int billId;

	private String billNum;

	private String passengerName;

	private Date saleDate;

	private double accountRecv;

	// 成本
	private Double cost;

	private double profit;

	private String pnrNo;

	private String remark;

	private String payMemo;

	/**
	 * 公布运价
	 */
	private double parvalue;

	/**
	 * 实际销售运价
	 */
	private double price;


	private double tax;

	/**
	 * 机场税
	 */
	private double airportTax;

	/**
	 * 燃油附加费
	 */
	private double fuelSurcharge;

	private double commissionRate;

	private double commissionRateExt;

	private double commission;

	private double customerCommissionRate;

	private double discount;

	private double discount2;

	private double hcharge;

	private double serviceCharge;

	private double lowFare;

	private Double insurance;

	/**
	 * 行程，冗余字段
	 */
	private String routeFlightNo;

	/**
	 * 第一段的起飞日期
	 */
	private String routeDate;

	private String routeSegInfo;

	private String routeClass;

	private String routeDetail;

	private List<FlightInfo> flights;

	private String operator;

	/**
	 * 出票日期
	 */
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date etdzDate;

	private String payMode;


	/**
	 * 是否已付款
	 * 0/null: 未付款
	 * 1: 已付款
	 */
	private String bePaid;

	/**
	 * 使用状态
	 */
	private String useStatus;

	private String dcity; // length = 3 ?

	private String acity; // length = 3 ?

	/**
	 * 是否已审核
	 */
	private String audited;

    /**
     * 供应商
     */
	private SupplierDto supplier;

    /**
     * 出票付款方式
     */
	private PaymentMethodDto paymentMethod;


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}


	public String getTicketNo() {
		return ticketNo;
	}

	public void setTicketNo(String ticketNo) {
		this.ticketNo = ticketNo;
	}

	public String getTicketClass() {
		return ticketClass;
	}

	public void setTicketClass(String ticketClass) {
		this.ticketClass = ticketClass;
	}

	public String getPassengerName() {
		return passengerName;
	}

	public void setPassengerName(String passengerName) {
		this.passengerName = passengerName;
	}

	public Date getSaleDate() {
		return saleDate;
	}

	public void setSaleDate(Date saleDate) {
		this.saleDate = saleDate;
	}

	public double getAccountRecv() {
		return accountRecv;
	}

	public void setAccountRecv(double accountRecv) {
		this.accountRecv = accountRecv;
	}

	public double getProfit() {
		return DecimalUtil.keepScale2(profit);
	}

	public void setProfit(double profit) {
		this.profit = profit;
	}

	public String getPnrNo() {
		return pnrNo;
	}

	public void setPnrNo(String pnrNo) {
		this.pnrNo = pnrNo;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public double getParvalue() {
		return parvalue;
	}

	public void setParvalue(double parvalue) {
		this.parvalue = parvalue;
	}

	public double getTax() {
		return tax;
	}

	public void setTax(double tax) {
		this.tax = tax;
	}

	public double getCommissionRate() {
		return commissionRate;
	}

	public void setCommissionRate(double commissionRate) {
		this.commissionRate = commissionRate;
	}

	public double getCommissionRateExt() {
		return commissionRateExt;
	}

	public void setCommissionRateExt(double commissionRateExt) {
		this.commissionRateExt = commissionRateExt;
	}

	public double getCommission() {
		return commission;
	}

	public void setCommission(double commission) {
		this.commission = commission;
	}

	public double getCustomerCommissionRate() {
		return customerCommissionRate;
	}

	public void setCustomerCommissionRate(double customerCommissionRate) {
		this.customerCommissionRate = customerCommissionRate;
	}

	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public double getDiscount2() {
		return discount2;
	}

	public void setDiscount2(double discount2) {
		this.discount2 = discount2;
	}

	public double getHcharge() {
		return hcharge;
	}

	public void setHcharge(double hcharge) {
		this.hcharge = hcharge;
	}

	public double getServiceCharge() {
		return serviceCharge;
	}

	public void setServiceCharge(double serviceCharge) {
		this.serviceCharge = serviceCharge;
	}

	public double getLowFare() {
		return lowFare;
	}

	public void setLowFare(double lowFare) {
		this.lowFare = lowFare;
	}

	/**
	 * @return the airportTax
	 */
	public double getAirportTax() {
		return airportTax;
	}

	/**
	 * @param airportTax the airportTax to set
	 */
	public void setAirportTax(double airportTax) {
		this.airportTax = airportTax;
	}

	/**
	 * @return the fuelSurcharge
	 */
	public double getFuelSurcharge() {
		return fuelSurcharge;
	}

	/**
	 * @param fuelSurcharge the fuelSurcharge to set
	 */
	public void setFuelSurcharge(double fuelSurcharge) {
		this.fuelSurcharge = fuelSurcharge;
	}

	public String getBalanceCode() {
		return balanceCode;
	}

	public void setBalanceCode(String balanceCode) {
		this.balanceCode = balanceCode;
	}

	public String getBillNum() {
		return billNum == null ? "" : billNum.trim();
	}

	public void setBillNum(String billNum) {
		this.billNum = billNum;
	}

	public String getRouteFlightNo() {
		if (routeFlightNo == null) {
      return "";
    } else {
      return routeFlightNo;
    }
	}

	public void setRouteFlightNo(String routeFlightNo) {
		this.routeFlightNo = routeFlightNo;
	}

	public String getRouteDate() {
		if (routeDate == null) {
      return "";
    } else {
      return routeDate;
    }
	}

	public void setRouteDate(String routeDate) {
		this.routeDate = routeDate;
	}

	public String getRouteSegInfo() {
		if (routeSegInfo == null) {
      return "";
    } else {
      return routeSegInfo;
    }
	}

	public void setRouteSegInfo(String routeSegInfo) {
		this.routeSegInfo = routeSegInfo;
	}

	public String getRouteDetail() {
		if (routeDetail == null) {
      return "";
    } else {
      return routeDetail;
    }
	}

	public void setRouteDetail(String routeDetail) {
		this.routeDetail = routeDetail;
	}

	public String getOperator() {
		return operator;
	}

	public void setOperator(String operator) {
		this.operator = operator;
	}

	public Date getEtdzDate() {
		return etdzDate;
	}

	public void setEtdzDate(Date etdzDate) {
		this.etdzDate = etdzDate;
	}

	public String getPayMode() {
		return payMode;
	}

	public void setPayMode(String payMode) {
		this.payMode = payMode;
	}

	public Double getInsurance() {
		return insurance;
	}

	public void setInsurance(Double insurance) {
		this.insurance = insurance;
	}

	public String getBePaid() {
		return bePaid;
	}

	public void setBePaid(String bePaid) {
		this.bePaid = bePaid;
	}

	public String getUseStatus() {
		return useStatus;
	}

	public void setUseStatus(String useStatus) {
		this.useStatus = useStatus;
	}

	public String getDcity() {
		return dcity;
	}

	public void setDcity(String dcity) {
		this.dcity = dcity;
	}

	public String getAcity() {
		return acity;
	}

	public void setAcity(String acity) {
		this.acity = acity;
	}

	public String getRouteClass() {
		return routeClass;
	}

	public void setRouteClass(String routeClass) {
		this.routeClass = routeClass;
	}

	public String getAudited() {
		return audited;
	}

	public void setAudited(String audited) {
		this.audited = audited;
	}

	public String getPayMemo() {
		return payMemo;
	}

	public void setPayMemo(String payMemo) {
		this.payMemo = payMemo;
	}

	public double getCost() {
		return cost == null ? 0 : cost;
	}

	public void setCost(Double cost) {
		this.cost = cost;
	}

    public SupplierDto getSupplier() {
        return supplier;
    }

    public void setSupplier(SupplierDto supplier) {
        this.supplier = supplier;
    }

    public PaymentMethodDto getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethodDto paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

	public int getBillId() {
		return billId;
	}

	public void setBillId(int billId) {
		this.billId = billId;
	}

	public List<FlightInfo> getFlights() {
		if (flights == null) {
      flights = new ArrayList<>();
    }
		return flights;
	}

	public void setFlights(List<FlightInfo> flights) {
		this.flights = flights;
	}

	public Date getOpDate() {
		return opDate;
	}

	public double getAirChangeCharge() {
		return airChangeCharge;
	}

	public String getNewTicketNo() {
		return newTicketNo;
	}

	public String getNewPnrNo() {
		return newPnrNo;
	}

	public String getOldPnrNo() {
		return oldPnrNo;
	}

	public int getIntlTicket() {
		return intlTicket;
	}
}
